import { request } from 'umi';

// GET request
export function get<T>(
  url: string,
  params?: { [key: string]: any },
): Promise<T> {
  return request(url, {
    method: 'GET',
    params: { ...params },
  });
}

// POST request
export const post = <T>(
  url: string,
  data?: { [key: string]: any },
): Promise<T> => {
  return request(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: data,
  });
};
